package com.javaweb.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.javaweb.admin.entity.KdlQffAttach;
import com.javaweb.admin.entity.KdlQffFeedback;
import com.javaweb.admin.entity.SaleOrder;
import com.javaweb.admin.query.KdlQffFeedbackQuery;
import com.javaweb.admin.query.ReturnQuery;
import com.javaweb.admin.vo.kdlqfffeedback.KdlQffFeedbackVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

public interface KdlQffFeedbackMapper extends BaseMapper<KdlQffFeedback> {

    @Select("select isnull(left(max(principalorderno),8)+right('000'+convert(varchar(3),convert(int,right(max(principalorderno),3))+1),3),'FK'+convert(varchar(6),getdate(),112)+'001') from kdl_qff_feedback where principalorderno like '%'+convert(varchar(6),getdate(),112)+'%'")
    String getPrincipalOrderNo();

    IPage<KdlQffFeedbackVo> getQffFeedbackList(IPage<KdlQffFeedbackVo> page, @Param("req") KdlQffFeedbackQuery req);

    @Select("select * from kdl_qff_attach where isnull(status,'')=''")
    List<KdlQffAttach> getQffAttachList();

    @Select("select org_code from v_kdl_nc_po_order where vbillcode=#{orderno} union select org_code from v_kdl_nc_so_order where vbillcode=#{orderno}")
    String getCompanyCode(String orderno);

    @Select("select isnull(convert(varchar(8),convert(date,max(erdat)),112),'20240601') from kdl_qff_feedback")
    String GetMaxSyncTime();

    @Select("select * from kdl_qff_feedback where principalorderno=#{principalorderno}")
    KdlQffFeedbackVo getQffFeedback(String principalorderno);


}


